import axios from "axios";
import { BASE_URL,OUT_TIME } from "./baseURL"

class HyReques {
    constructor(baseURL,outTime = 10000) {
        this.instance = axios.create({
            baseURL,
            outTime,
        })
    }


    request(options){
        return new Promise((resolve,reject) => {
            this.instance(options).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    }

    get(url,params = {},config = {}){
        return this.request({
          method: 'get',
          url,
          params,
          ...config
        })
      }
    
    post(url,data = {},config = {}){
      return this.request({
        method: 'post',
        url,
        data,
        ...config
      })
    }
}

export default new HyReques(BASE_URL,OUT_TIME)